#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
const int N = 410;

ll n, m, Q;
ll d[N][N];

void floyd()
{
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main()
{
    close();
    cin >> n >> m >> Q;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (i == j) d[i][j] = 0;
            else d[i][j] = 1e18;

    while (m--)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        d[a][b] = min(d[a][b], c);
        d[b][a] = d[a][b];
    }

    floyd();

    while (Q--)
    {
        ll a, b;
        cin >> a >> b;

        ll t = d[a][b];
        if (t >= 1e12) cout << -1 << '\n'; //这里要除一半应为有可能到不了但是更新了
        else cout << t << '\n';
    }

    return 0;
}